home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Kara Collection
/
Kara Collection v3.0 (1996-09-12)(Cloanto).iso
/
utilities
/
h
/
0
/
6
/
4
/
rexx
/
animtext.pprx
< prev
next >
Wrap
Text File
|
1996-08-31
|
10KB
|
470 lines
/* PPaint Amiga Rexx script - Copyright © 1995, 1996 Cloanto Italia srl */
/*
$VER: AnimText.pprx 1.1
This script renders a text string using AnimFonts by Kara Computer
Graphics. The resulting animation is played or placed in the current
brush
For more information, or suggestions, please address E-mail to
<info@cloanto.com>
*/
absh_dir = 'KaraCD:AnimFonts/AnimBrushes'
data_dir = 'KaraCD:AnimFonts/AnimBrushes'
MYPORT = 'PPAINT'
IF ~SHOW('P', MYPORT) THEN DO
IF EXISTS('PPaint:PPaint') THEN DO
ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
DO 30 WHILE ~SHOW('P',MYPORT)
ADDRESS COMMAND 'Wait >NIL: 1 SEC'
END
END
ELSE DO
SAY "Personal Paint could not be loaded."
EXIT 10
END
END
IF ~SHOW('P', MYPORT) THEN DO
SAY 'Personal Paint Rexx port could not be opened.'
EXIT 10
END
ADDRESS VALUE MYPORT
OPTIONS RESULTS
OPTIONS FAILAT 10000
Version 'REXX'
IF RESULT < 4 THEN DO
errmess = 'This script requires a newer_version of Personal Paint.'
SAY errmess
RequestNotify 'PROMPT="'errmess'"'
EXIT 10
END
FreeBrush
IF RC ~= 0 THEN EXIT RC
/* Localization */
Get 'LANG'
IF RESULT = 1 THEN DO /* Deutsch */
req_title = 'AnimText-Einstellungen'
lst_gad_txt = 'Anim_Font:'
str_gad_txt = '_Text:'
str_gad_val = 'Text'
cyc_gad_txt = '_Darstellen:'
cyc_gad_val1 = 'Von Links nach Rechts'
cyc_gad_val2 = 'Gleichzeitig'
num_gad1_txt = 'Ab_stand:'
num_gad2_txt = 'Einzelbild-_Offset:'
chk_gad_txt = 'Anim-_Brush:'
no_animfont = 'AnimFonts konnten nicht_gefunden werden'
no_datafile = 'Fontdatei konnte nicht_gefunden werden'
no_env = 'Andere Umgebung_kann nicht erstellt werden'
END
ELSE IF RESULT = 3 THEN DO /* Français */
req_title = "Réglages d'AnimText"
lst_gad_txt = 'Anim_Font :'
str_gad_txt = '_Texte :'
str_gad_val = 'Texte'
cyc_gad_txt = 'Apparitio_n :'
cyc_gad_val1 = 'De gauche à droite'
cyc_gad_val2 = 'Simultanément'
num_gad1_txt = 'E_spacement :'
num_gad2_txt = '_Retard :'
chk_gad_txt = '_Brosse animée :'
no_animfont = 'AnimFonts non trouvées'
no_datafile = 'Impossible de trouver_le fichier de données_de la police'
no_env = "Impossible de créer_l'autre environnement"
END
ELSE IF RESULT = 2 THEN DO /* Italiano */
req_title = 'Parametri AnimText'
lst_gad_txt = 'Anim_Font:'
str_gad_txt = '_Testo:'
str_gad_val = 'Testo'
cyc_gad_txt = '_Scrittura:'
cyc_gad_val1 = 'Da sinistra a destra'
cyc_gad_val2 = 'Simultanea'
num_gad1_txt = '_Spaziatura:'
num_gad2_txt = 'Sp_ostamento:'
chk_gad_txt = 'Anim-_Brush:'
no_animfont = 'Impossibile trovare AnimFont'
no_datafile = 'Impossibile aprire_il file dati'
no_env = 'Impossibile creare_ambiente alternativo'
END
ELSE DO /* English */
req_title = 'AnimText Settings'
lst_gad_txt = 'Anim_Font:'
str_gad_txt = '_Text:'
str_gad_val = 'Text'
cyc_gad_txt = '_Render:'
cyc_gad_val1 = 'Left to right'
cyc_gad_val2 = 'Simultaneously'
num_gad1_txt = '_Spacing:'
num_gad2_txt = 'F_rame Offset:'
chk_gad_txt = 'Anim-_Brush:'
no_animfont = 'AnimFonts not found'
no_datafile = 'Font data file_cannot be found'
no_env = 'Other environment_cannot be created'
END
/* Build the list of available AnimFonts */
ftot = 0
tmpfname = 'T:pprx_temp.'PRAGMA('ID')
ADDRESS COMMAND 'List >'tmpfname' 'absh_dir' NOHEAD LFORMAT="%s" DIRS'
IF RC = 0 THEN DO
ADDRESS COMMAND 'Sort 'tmpfname tmpfname'.s'
IF RC = 0 THEN DO
ADDRESS COMMAND 'Delete >NIL: 'tmpfname
tmpfname = tmpfname'.s'
END
IF OPEN('listfile', tmpfname, R) THEN DO
DO FOREVER
fline = READLN('listfile')
IF EOF('listfile') THEN BREAK
ftot = ftot + 1
fontname.ftot = fline
END
CALL CLOSE('listfile')
END
END
ADDRESS COMMAND 'Delete >NIL: 'tmpfname
IF ftot = 0 THEN DO
SAY no_animfont
RequestNotify 'PROMPT="'no_animfont'"'
EXIT 10
END
/* Build and show the settings requester */
font = LoadSet('Font', 0)
str_gad_val = LoadSet('Text', str_gad_val)
render = LoadSet('Render', 0)
spacing = LoadSet('Spacing', 0)
offset = LoadSet('Offset', 0)
getbsh = LoadSet('Getbsh', 1)
req = '"LIST = ""'lst_gad_txt'"", 'ftot', 'font', 20, 5' /* max 5 rows to fit into a 320x200 screen */
DO f = 1 TO ftot
req = req || ', ""' || fontname.f || '""'
END
req = req ||,
' STRING = ""'str_gad_txt'"", 256, ""'str_gad_val'"" ' ||,
'CYCLE = ""'cyc_gad_txt'"", 2, 'render', ""'cyc_gad_val1'"", ""'cyc_gad_val2'"" ' ||,
'INTSTR = ""'num_gad1_txt'"", -32768, 32767, 'spacing' ' ||,
'INTSTR = ""'num_gad2_txt'"", -32768, 32767, 'offset' ' ||,
'CHECK = ""'chk_gad_txt'"", 'getbsh' "'
Request resize '"'req_title'"' req
IF RC = 0 THEN DO
font = RESULT.1
text = RESULT.2
render = RESULT.3
spacing = RESULT.4
offset = RESULT.5
getbsh = RESULT.6
CALL SaveSet('Font', font) /* setting persistence */
CALL SaveSet('Text', text)
CALL SaveSet('Render', render)
CALL SaveSet('Spacing', spacing)
CALL SaveSet('Offset', offset)
CALL SaveSet('Getbsh', getbsh)
END
ELSE EXIT RC
font = font + 1
abshpath = absh_dir'/'fontname.font'/'
dataname = data_dir'/'fontname.font'.data'
len = LENGTH(text)
fontdata. = 'undef'
/* Read data file */
IF OPEN('datafile', dataname, R) THEN DO
READLN('datafile')
skip_first = READLN('datafile')
frm_offset = READLN('datafile')
DO FOREVER
fline = READLN('datafile')
IF EOF('datafile') THEN BREAK
PARSE VAR fline chr nm spc hdx
fontdata.name.chr = nm
fontdata.space.chr = spc
fontdata.handx.chr = hdx
END
CALL CLOSE('datafile')
END
ELSE DO
SAY no_datafile
RequestNotify 'PROMPT="'no_datafile'"'
EXIT 10
END
/* Render the text */
LockGUI
Get SETTING IMAGEW
img_width = RESULT
Get SETTING DISPLAY
img_disp = RESULT
SwitchEnv
FreeEnv QUERY
IF RC ~= 0 THEN DO
UnlockGUI
EXIT RC
END
DelFrames ALL FORCE
ClearImage
PaintMode MATTE
xmax = 0
ymax = 0
error = 0
IF render = 0 THEN DO /* Left to right */
xpos = 0
ypos = 0
first = 1
DO c = 1 TO len
chr = UseChar(SUBSTR(text, c, 1))
IF chr = 32 | chr = 60 | chr = 62 THEN DO
IF fontdata.space.chr ~= 'undef' THEN
xpos = xpos + fontdata.space.chr + spacing
END
ELSE DO
LoadAnimBrush '"'abshpath || fontdata.name.chr'"' FORCE QUIET NOPROGRESS
IF RC = 0 THEN DO
GetBrushAttr FRAMES
frm = RESULT
IF skip_first THEN
frm = frm - 1
IF first THEN DO
first = 0
error = SetupEnv(img_width, img_disp)
IF error ~= 0 THEN
LEAVE c
UseBrushPalette
IF fontdata.handx.chr > 0 THEN
xpos = fontdata.handx.chr
AddFrames frm
END
ELSE DO
GetFrameNum
tot = RESULT
pos = tot + frm_offset + offset
add = frm - (tot - pos)
IF add > 0 THEN
AddFrames add AFTER tot
SetFramePos pos + 1
END
SetBrushAttr FRPOS 2 HANDLEX fontdata.handx.chr HANDLEY 0
DO f = 1 TO frm
PutBrush xpos ypos
SetFramePos NEXT
END
GetBrushAttr WIDTH
x1 = xpos - fontdata.handx.chr + RESULT - 1
IF x1 > xmax THEN
xmax = x1
GetBrushAttr HEIGHT
y1 = ypos + RESULT - 1
IF y1 > ymax THEN
ymax = y1
xpos = xpos + fontdata.space.chr + spacing
END
END
END
END
ELSE DO /* Simultaneously */
max_frm = 0
DO c = 1 TO len
chr = UseChar(SUBSTR(text, c, 1))
IF chr ~= 32 & chr ~= 60 & chr ~= 62 THEN DO
LoadAnimBrush '"'abshpath || fontdata.name.chr'"' FORCE QUIET NOPROGRESS
IF RC = 0 THEN DO
GetBrushAttr FRAMES
frm = RESULT
IF frm > max_frm THEN
max_frm = frm
END
END
END
error = SetupEnv(img_width, img_disp)
IF error = 0 THEN DO
IF skip_first THEN
max_frm = max_frm - 1
UseBrushPalette
AddFrames max_frm
DO f = 1 TO max_frm
xpos = 0
ypos = 0
first = 1
DO c = 1 TO len
chr = UseChar(SUBSTR(text, c, 1))
IF chr = 32 | chr = 60 | chr = 62 THEN DO
IF fontdata.space.chr ~= 'undef' THEN
xpos = xpos + fontdata.space.chr + spacing
END
ELSE DO
LoadAnimBrush '"'abshpath || fontdata.name.chr'"' FORCE QUIET NOPROGRESS
IF RC = 0 THEN DO
GetBrushAttr FRAMES
frm = RESULT
IF first THEN DO
first = 0
IF fontdata.handx.chr > 0 THEN
xpos = fontdata.handx.chr
END
fpos = f + 1
IF fpos > frm THEN DO
IF skip_first THEN
fpos = frm
ELSE
fpos = 1
END
SetBrushAttr FRPOS fpos HANDLEX fontdata.handx.chr HANDLEY 0
PutBrush xpos ypos
IF f = 1 THEN DO
GetBrushAttr WIDTH
x1 = xpos - fontdata.handx.chr + RESULT - 1
IF x1 > xmax THEN
xmax = x1
GetBrushAttr HEIGHT
y1 = ypos + RESULT - 1
IF y1 > ymax THEN
ymax = y1
END
xpos = xpos + fontdata.space.chr + spacing
END
END
END
SetFramePos NEXT
END
END
END
IF error = 0 THEN DO
SetFramePos 1
IF getbsh THEN DO
GetFrameNum
frm = RESULT
GetRectBrush 0 0 xmax ymax frm
IF RC = 0 THEN
FreeEnv FORCE
END
ELSE DO
FreeBrush FORCE
Play FORCE
END
END
ELSE DO
SAY no_env
RequestNotify 'PROMPT="'no_env'"'
END
UnlockGUI
EXIT 0
UseChar:
ch = ARG(1)
code = C2D(ch)
IF fontdata.space.code = 'undef' THEN DO
IF ch >= 'A' & ch <= 'Z' THEN
code = code + 32
ELSE IF ch >= 'a' & ch <= 'z' THEN
code = code - 32
IF fontdata.space.code = 'undef' THEN
code = 32
END
RETURN code
SetupEnv:
imgw = ARG(1)
imgd = ARG(2)
GetBrushAttr COLORS
cnum = RESULT
GetBrushAttr HEIGHT
imgh = RESULT
Set '"IMAGEW='imgw'" "IMAGEH='imgh'" "COLORS='cnum'" "DISPLAY='imgd'" "SCREENW=-1" "SCREENH='imgh'" "ASCROLL=0"'
RETURN RC
SaveSet:
sname = ARG(1)
val = ARG(2)
IF OPEN('settingfile', 'ENV:PP_AnimText_'sname, W) THEN DO
CALL WRITECH('settingfile', val)
CALL CLOSE('settingfile')
END
RETURN
LoadSet:
sname = ARG(1)
def_val = ARG(2)
val = def_val
IF OPEN('settingfile', 'ENV:PP_AnimText_'sname, R) THEN DO
val = READCH('settingfile', 65535)
CALL CLOSE('settingfile')
END
/* encode quotes for the Request command ('"' -> '\""') */
qpos_start = 1
DO FOREVER
qpos = INDEX(val, '"', qpos_start)
IF qpos = 0 THEN BREAK
val = INSERT('\"', val, qpos-1)
qpos_start = qpos + 3
END
RETURN val